import { defineStore } from "pinia";
import { startSakura, stopp } from "@/utils/sakuraPlus.js";
export const homepage = defineStore("homepage", {
  state: () => {
    return {
      innerWidth: null, //当前窗口的宽度
      innerHeight: null, //当前窗口的高度
      backgroundShow: false, // 壁纸预览状态
      imagetype: 1, //图片状态
      currentimage:"",
      loadstate: true, //加载状态
      searchshow: false, //进入搜索状态
      keyword: "", // 关键字
      changeSE: false, // 搜索引擎展开栏
      // 选择搜索引擎
      SE_list: [
        {
          id: 0,
          name: "百度",
          icon: "baidu",
          searchurl:
            "https://www.baidu.com/s?&tn=68018901_2_oem_dgie=utf-8&wd=",
        },
        {
          id: 1,
          name: "谷歌",
          icon: "google",
          searchurl: "https://www.google.com/search?q=",
        },
        {
          id: 2,
          name: "必应",
          icon: "bing",
          searchurl: "http://www.bing.com/search?q=",
        },
        {
          id: 3,
          name: "bilibili",
          icon: "bilibili",
          searchurl: "https://search.bilibili.com/all?keyword=",
        },
        {
          id: 4,
          name: "抖音",
          icon: "douyin",
          searchurl: "https://www.douyin.com/search/",
        },
      ],
      SE_type: 0, // 搜索引擎类型
      SakuraEffects: true, //樱花特效
      menuSelectShow: false, //菜单栏状态
      loginshow:false, //登录栏显示
      setshow:false //设置栏显示
    };
  },
  actions: {
    // 进入搜索状态
    Search() {
      document.getElementsByTagName("body")[0].className = "onsearch";
      this.searchshow = true;
    },
    // 退出搜索状态
    clearsearch() {
      document.getElementsByTagName("body")[0].className = "";
      this.searchshow = false;
      this.changeSE = false;
      this.keyword = "";
      this.menuSelectShow = false;
      return false;
    },
    // 开启樱花特效
    Sakura() {
      startSakura();
    },
    // 关闭樱花特效
    clearSakura() {
      stopp();
    },
    // 打开菜单栏
    openMenuList() {
      this.Search();
      this.menuSelectShow = true;
    },
    // 关闭菜单栏
    closeMenuList() {
      this.clearsearch();
      this.menuSelectShow = false;
    },
  },
  getters: {},
});
